
    /*
    ===============================================================================================================================================
    ===== WARRNING: THE FOLLOWING CODE IS AUTO GENERATED, DO NOT MODIFY THIS CODE! EXTEND THIS CODE BY USING PARTIAL CLASSES AND SUB CLASSES. =====
    ===============================================================================================================================================
    */

    using System;
    using System.Collections.Concurrent;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Threading;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Threading.Tasks;
    
      namespace BigBank.Contracts.Base.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Base/V1";
      public const string XmlSchema = "http://services.bigbank.com/Base/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Base.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="BaseServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BaseServiceRequest 
      { }

      [DataContract(Name="BatchBaseServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBaseServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, BaseServiceRequest> Requests { get; set; }
      }

      

      [DataContract(Name="BaseServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BaseServiceResponse  
      { }

      [DataContract(Name="BatchBaseServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBaseServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, BaseServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, BaseServiceFault> Faults { get; set; }
      }

      
      }

      namespace Faults
      {
      [DataContract(Name="BaseServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class BaseServiceFault 
      { }

      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="BaseService", Namespace=Namespaces.XmlService)]
        public partial interface IBaseService
        {
        
        }

        [ServiceContract(Name="BatchBaseService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchBaseService
        {
        [FaultContract(typeof(BaseServiceFault))]
        [OperationContract(Name="Process")]
        BatchBaseServiceResponse Process(BatchBaseServiceRequest request);
        }
        
        public partial interface IBaseServiceClient
        {
          IBaseService Service { get; set; }
        }
      }

      namespace Tests
      {
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class BaseServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected BaseServiceAspect(int order) { Order = order; }
          public virtual void OnPreBaseServiceOperation(ref BaseServiceRequest request) { }
          public virtual void OnPostBaseServiceOperation(ref BaseServiceRequest request, ref BaseServiceResponse response) { }
          public virtual void OnBaseServiceOperationError(ref BaseServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Base.V1.Services.MockBaseService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Base.V1.Services.MockBaseService">
      <endpoint bindingNamespace="http://services.bigbank.com/Base/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Base.V1.Interfaces.IBaseService"/>
      </service>
      */

      [ServiceBehavior(Name = "BaseService", Namespace = Namespaces.XmlService)]
      public partial class MockBaseService : BaseServiceBase
      {
      
      }
      public abstract partial class BaseServiceBase : IBaseService
      {
      #region Section for dealing with aspects.
      private IList<BaseServiceAspect>   aspects = null;
      private IList<BaseServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<BaseServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(BaseServiceAspect), true))
            aspects.Add((aspect as BaseServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event BaseServiceRequestHandler PreBaseServiceOperation;
      public event BaseServiceResponseHandler PostBaseServiceOperation;
      public event BaseServiceErrorHandler BaseServiceOperationError;
      
      public delegate void BaseServiceRequestHandler(ref BaseServiceRequest request);
      public delegate void BaseServiceResponseHandler(ref BaseServiceRequest request, ref BaseServiceResponse response);
      public delegate void BaseServiceErrorHandler(ref BaseServiceRequest request, ref Exception exception);
      
      protected void RaisePreBaseServiceOperation(BaseServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreBaseServiceOperation(ref request);
        if (PreBaseServiceOperation != null) PreBaseServiceOperation(ref request); }
      protected void RaisePostBaseServiceOperation(BaseServiceRequest request, BaseServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostBaseServiceOperation(ref request, ref response);
        if (PostBaseServiceOperation != null) PostBaseServiceOperation(ref request, ref response); }
      protected void RaiseBaseServiceOperationError(BaseServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnBaseServiceOperationError(ref request, ref exception);
        if (BaseServiceOperationError != null) BaseServiceOperationError(ref request, ref exception); }
       }
      
      public class BatchBaseService : IBatchBaseService
      {
      private readonly IBaseService service;
      private readonly int maxDegreeOfParallelism;
      public BatchBaseService(IBaseService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchBaseServiceResponse response = new BatchBaseServiceResponse {
        Responses = new ConcurrentDictionary<string, BaseServiceResponse>(),
        Faults = new ConcurrentDictionary<string, BaseServiceFault>() };

      public BatchBaseServiceResponse Process(BatchBaseServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, BaseServiceRequest> keyValuePair) {
      try
      {
      
      }
      catch(FaultException<BaseServiceFault> fault)
      {
      
      }
      }
      }

      public partial class BaseServiceProxy : ClientBase<IBaseService>, IBaseService
      {
      
      }

      public class BatchBaseServiceProxy : ClientBase<IBatchBaseService>, IBatchBaseService
        {
        

        public BatchBaseServiceResponse Process(BatchBaseServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<BaseServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<BaseServiceRequest>;
        IDictionary<BaseServiceRequest, BaseServiceResponse> responses;
        IDictionary<BaseServiceRequest, BaseServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
         }

        foreach (var item in faults) {
         }
        }

        public void Process(
        IList<BaseServiceRequest> requests,
        out IDictionary<BaseServiceRequest, BaseServiceResponse> responses,
        out IDictionary<BaseServiceRequest, BaseServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchBaseServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class BaseServiceClient : IBaseServiceClient
        {
          public BaseServiceClient(IBaseService service) { Service = service; }
          public IBaseService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.Platform.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Base.V1.Messages ;
        using BigBank.Contracts.Base.V1.Faults;
        using BigBank.Contracts.Base.V1.Interfaces;
        using BigBank.Contracts.Base.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Platform/V1";
      public const string XmlSchema = "http://services.bigbank.com/Platform/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Platform.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="PlatformServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class PlatformServiceRequest 
        : BaseServiceRequest
      
      { }

      [DataContract(Name="BatchPlatformServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchPlatformServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, PlatformServiceRequest> Requests { get; set; }
      }

      

      [DataContract(Name="PlatformServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class PlatformServiceResponse  
        : BaseServiceResponse
      
      { }

      [DataContract(Name="BatchPlatformServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchPlatformServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, PlatformServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, PlatformServiceFault> Faults { get; set; }
      }

      
      }

      namespace Faults
      {
      [DataContract(Name="PlatformServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class PlatformServiceFault 
        : BaseServiceFault
      
      { }

      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="PlatformService", Namespace=Namespaces.XmlService)]
        public partial interface IPlatformService
          : IBaseService
        {
        
        }

        [ServiceContract(Name="BatchPlatformService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchPlatformService
        {
        [FaultContract(typeof(PlatformServiceFault))]
        [OperationContract(Name="Process")]
        BatchPlatformServiceResponse Process(BatchPlatformServiceRequest request);
        }
        
        public partial interface IPlatformServiceClient
        {
          IPlatformService Service { get; set; }
        }
      }

      namespace Tests
      {
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class PlatformServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected PlatformServiceAspect(int order) { Order = order; }
          public virtual void OnPrePlatformServiceOperation(ref PlatformServiceRequest request) { }
          public virtual void OnPostPlatformServiceOperation(ref PlatformServiceRequest request, ref PlatformServiceResponse response) { }
          public virtual void OnPlatformServiceOperationError(ref PlatformServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Platform.V1.Services.MockPlatformService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Platform.V1.Services.MockPlatformService">
      <endpoint bindingNamespace="http://services.bigbank.com/Platform/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Platform.V1.Interfaces.IPlatformService"/>
      </service>
      */

      [ServiceBehavior(Name = "PlatformService", Namespace = Namespaces.XmlService)]
      public partial class MockPlatformService : PlatformServiceBase
      {
      
      }
      public abstract partial class PlatformServiceBase : BaseServiceBase,
      IPlatformService
      {
      #region Section for dealing with aspects.
      private IList<PlatformServiceAspect>   aspects = null;
      private IList<PlatformServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<PlatformServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(PlatformServiceAspect), true))
            aspects.Add((aspect as PlatformServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event PlatformServiceRequestHandler PrePlatformServiceOperation;
      public event PlatformServiceResponseHandler PostPlatformServiceOperation;
      public event PlatformServiceErrorHandler PlatformServiceOperationError;
      
      public delegate void PlatformServiceRequestHandler(ref PlatformServiceRequest request);
      public delegate void PlatformServiceResponseHandler(ref PlatformServiceRequest request, ref PlatformServiceResponse response);
      public delegate void PlatformServiceErrorHandler(ref PlatformServiceRequest request, ref Exception exception);
      
      protected void RaisePrePlatformServiceOperation(PlatformServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPrePlatformServiceOperation(ref request);
        if (PrePlatformServiceOperation != null) PrePlatformServiceOperation(ref request); }
      protected void RaisePostPlatformServiceOperation(PlatformServiceRequest request, PlatformServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostPlatformServiceOperation(ref request, ref response);
        if (PostPlatformServiceOperation != null) PostPlatformServiceOperation(ref request, ref response); }
      protected void RaisePlatformServiceOperationError(PlatformServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnPlatformServiceOperationError(ref request, ref exception);
        if (PlatformServiceOperationError != null) PlatformServiceOperationError(ref request, ref exception); }
       }
      
      public class BatchPlatformService : IBatchPlatformService
      {
      private readonly IPlatformService service;
      private readonly int maxDegreeOfParallelism;
      public BatchPlatformService(IPlatformService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchPlatformServiceResponse response = new BatchPlatformServiceResponse {
        Responses = new ConcurrentDictionary<string, PlatformServiceResponse>(),
        Faults = new ConcurrentDictionary<string, PlatformServiceFault>() };

      public BatchPlatformServiceResponse Process(BatchPlatformServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, PlatformServiceRequest> keyValuePair) {
      try
      {
      
      }
      catch(FaultException<PlatformServiceFault> fault)
      {
      
      }
      }
      }

      public partial class PlatformServiceProxy : ClientBase<IPlatformService>, IPlatformService
      {
      
      }

      public class BatchPlatformServiceProxy : ClientBase<IBatchPlatformService>, IBatchPlatformService
        {
        

        public BatchPlatformServiceResponse Process(BatchPlatformServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<PlatformServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<PlatformServiceRequest>;
        IDictionary<PlatformServiceRequest, PlatformServiceResponse> responses;
        IDictionary<PlatformServiceRequest, PlatformServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
         }

        foreach (var item in faults) {
         }
        }

        public void Process(
        IList<PlatformServiceRequest> requests,
        out IDictionary<PlatformServiceRequest, PlatformServiceResponse> responses,
        out IDictionary<PlatformServiceRequest, PlatformServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchPlatformServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class PlatformServiceClient : IPlatformServiceClient
        {
          public PlatformServiceClient(IPlatformService service) { Service = service; }
          public IPlatformService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.Authorization.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Platform.V1.Messages ;
        using BigBank.Contracts.Platform.V1.Faults;
        using BigBank.Contracts.Platform.V1.Interfaces;
        using BigBank.Contracts.Platform.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Authorization/V1";
      public const string XmlSchema = "http://services.bigbank.com/Authorization/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Authorization.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="AuthorizationServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class AuthorizationServiceRequest 
        : PlatformServiceRequest
      
      { }

      [DataContract(Name="BatchAuthorizationServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchAuthorizationServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, AuthorizationServiceRequest> Requests { get; set; }
      }

      
        [DataContract(Name="AuthorizeRequestRequest", Namespace=Namespaces.XmlSchema)]
        public partial class AuthorizeRequestRequest : AuthorizationServiceRequest { }
      

      [DataContract(Name="AuthorizationServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class AuthorizationServiceResponse  
        : PlatformServiceResponse
      
      { }

      [DataContract(Name="BatchAuthorizationServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchAuthorizationServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, AuthorizationServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, AuthorizationServiceFault> Faults { get; set; }
      }

      
        [DataContract(Name="AuthorizeRequestResponse", Namespace=Namespaces.XmlSchema)]
        public partial class AuthorizeRequestResponse : AuthorizationServiceResponse { }
      
      }

      namespace Faults
      {
      [DataContract(Name="AuthorizationServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class AuthorizationServiceFault 
        : PlatformServiceFault
      
      { }

      
        [DataContract(Name="AuthorizeRequestFault", Namespace=Namespaces.XmlSchema)]
        public partial class AuthorizeRequestFault : AuthorizationServiceFault { }
      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="AuthorizationService", Namespace=Namespaces.XmlService)]
        public partial interface IAuthorizationService
          : IPlatformService
        {
        
          [FaultContract(typeof(AuthorizeRequestFault))]
          [OperationContract(Name="AuthorizeRequest")]
          AuthorizeRequestResponse AuthorizeRequest(AuthorizeRequestRequest request);
        
        }

        [ServiceContract(Name="BatchAuthorizationService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchAuthorizationService
        {
        [FaultContract(typeof(AuthorizationServiceFault))]
        [OperationContract(Name="Process")]
        BatchAuthorizationServiceResponse Process(BatchAuthorizationServiceRequest request);
        }
        
        public partial interface IAuthorizationServiceClient
        {
          IAuthorizationService Service { get; set; }
        }
      }

      namespace Tests
      {
      
        [TestClass]
        public partial class AuthorizeRequestTest
        {
        private AuthorizeRequestRequest request;
        private AuthorizeRequestResponse response;
        private IAuthorizationService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new AuthorizeRequestRequest();
        service = new MockAuthorizationService();
        response = service.AuthorizeRequest(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsAuthorizeRequestResponse()
        {
        Assert.IsInstanceOfType(response, typeof(AuthorizeRequestResponse));
        }

        }
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class AuthorizationServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected AuthorizationServiceAspect(int order) { Order = order; }
          public virtual void OnPreAuthorizationServiceOperation(ref AuthorizationServiceRequest request) { }
          public virtual void OnPostAuthorizationServiceOperation(ref AuthorizationServiceRequest request, ref AuthorizationServiceResponse response) { }
          public virtual void OnAuthorizationServiceOperationError(ref AuthorizationServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Authorization.V1.Services.MockAuthorizationService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Authorization.V1.Services.MockAuthorizationService">
      <endpoint bindingNamespace="http://services.bigbank.com/Authorization/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Authorization.V1.Interfaces.IAuthorizationService"/>
      </service>
      */

      [ServiceBehavior(Name = "AuthorizationService", Namespace = Namespaces.XmlService)]
      public partial class MockAuthorizationService : AuthorizationServiceBase
      {
      
        public override AuthorizeRequestResponse AuthorizeRequest(AuthorizeRequestRequest request) { 
        if (request == null)
          throw new FaultException<AuthorizeRequestFault>(new AuthorizeRequestFault(), "Request was null.");
          return new AuthorizeRequestResponse(); }
      
      }
      public abstract partial class AuthorizationServiceBase : PlatformServiceBase,
      IAuthorizationService
      {
      #region Section for dealing with aspects.
      private IList<AuthorizationServiceAspect>   aspects = null;
      private IList<AuthorizationServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<AuthorizationServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(AuthorizationServiceAspect), true))
            aspects.Add((aspect as AuthorizationServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event AuthorizationServiceRequestHandler PreAuthorizationServiceOperation;
      public event AuthorizationServiceResponseHandler PostAuthorizationServiceOperation;
      public event AuthorizationServiceErrorHandler AuthorizationServiceOperationError;
      
        public event AuthorizeRequestRequestHandler PreAuthorizeRequest;
        public event AuthorizeRequestResponseHandler PostAuthorizeRequest;
        public event AuthorizeRequestErrorHandler AuthorizeRequestError;
      
      public delegate void AuthorizationServiceRequestHandler(ref AuthorizationServiceRequest request);
      public delegate void AuthorizationServiceResponseHandler(ref AuthorizationServiceRequest request, ref AuthorizationServiceResponse response);
      public delegate void AuthorizationServiceErrorHandler(ref AuthorizationServiceRequest request, ref Exception exception);
      
        public delegate void AuthorizeRequestRequestHandler(ref AuthorizeRequestRequest request);
        public delegate void AuthorizeRequestResponseHandler(ref AuthorizeRequestRequest request, ref AuthorizeRequestResponse response);
        public delegate void AuthorizeRequestErrorHandler(ref AuthorizeRequestRequest request, ref Exception exception);
      
      protected void RaisePreAuthorizationServiceOperation(AuthorizationServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreAuthorizationServiceOperation(ref request);
        if (PreAuthorizationServiceOperation != null) PreAuthorizationServiceOperation(ref request); }
      protected void RaisePostAuthorizationServiceOperation(AuthorizationServiceRequest request, AuthorizationServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostAuthorizationServiceOperation(ref request, ref response);
        if (PostAuthorizationServiceOperation != null) PostAuthorizationServiceOperation(ref request, ref response); }
      protected void RaiseAuthorizationServiceOperationError(AuthorizationServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnAuthorizationServiceOperationError(ref request, ref exception);
        if (AuthorizationServiceOperationError != null) AuthorizationServiceOperationError(ref request, ref exception); }
      
      protected void RaisePreAuthorizeRequest(AuthorizeRequestRequest request) {
        if (PreAuthorizeRequest != null) PreAuthorizeRequest(ref request); }
      protected void RaisePostAuthorizeRequest(AuthorizeRequestRequest request, AuthorizeRequestResponse response) {
        if (PostAuthorizeRequest != null) PostAuthorizeRequest(ref request, ref response); }
      protected void RaiseAuthorizeRequestError(AuthorizeRequestRequest request, Exception exception) {
        if (AuthorizeRequestError != null) AuthorizeRequestError(ref request, ref exception); }
      
        public abstract AuthorizeRequestResponse AuthorizeRequest(AuthorizeRequestRequest request);
      AuthorizeRequestResponse  IAuthorizationService.AuthorizeRequest(AuthorizeRequestRequest request) {
        AuthorizeRequestResponse response = null;
        try {
        
        RaisePrePlatformServiceOperation(request);
        
        RaisePreAuthorizationServiceOperation(request);
        RaisePreAuthorizeRequest(request);
        response = AuthorizeRequest(request);
        RaisePostAuthorizeRequest(request, response);
        RaisePostAuthorizationServiceOperation(request, response);
        
          RaisePostPlatformServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaisePlatformServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (AuthorizationServiceOperationError == null) throw;
          RaiseAuthorizationServiceOperationError(request, exception);
          RaiseAuthorizeRequestError(request, exception); }
        return response; }
       }
      
      public class BatchAuthorizationService : IBatchAuthorizationService
      {
      private readonly IAuthorizationService service;
      private readonly int maxDegreeOfParallelism;
      public BatchAuthorizationService(IAuthorizationService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchAuthorizationServiceResponse response = new BatchAuthorizationServiceResponse {
        Responses = new ConcurrentDictionary<string, AuthorizationServiceResponse>(),
        Faults = new ConcurrentDictionary<string, AuthorizationServiceFault>() };

      public BatchAuthorizationServiceResponse Process(BatchAuthorizationServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, AuthorizationServiceRequest> keyValuePair) {
      try
      {
      
        if (keyValuePair.Value is AuthorizeRequestRequest)
        response.Responses.Add(keyValuePair.Key, service.AuthorizeRequest(keyValuePair.Value as AuthorizeRequestRequest));
      
      }
      catch(FaultException<AuthorizationServiceFault> fault)
      {
      
        if (fault.Detail is AuthorizeRequestFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as AuthorizeRequestFault);
      
      }
      }
      }

      public partial class AuthorizationServiceProxy : ClientBase<IAuthorizationService>, IAuthorizationService
      {
      
        public AuthorizeRequestResponse AuthorizeRequest(AuthorizeRequestRequest request)
        {
        return Channel.AuthorizeRequest(request);
        }
      
      }

      public class BatchAuthorizationServiceProxy : ClientBase<IBatchAuthorizationService>, IBatchAuthorizationService
        {
        
          public delegate void AuthorizeRequestResponseHandler(AuthorizeRequestRequest request, AuthorizeRequestResponse response);
          public delegate void AuthorizeRequestFaultHandler(AuthorizeRequestRequest request, AuthorizeRequestFault fault);
          public event AuthorizeRequestResponseHandler AuthorizeRequestResponse;
          public event AuthorizeRequestFaultHandler AuthorizeRequestFault;
        

        public BatchAuthorizationServiceResponse Process(BatchAuthorizationServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<AuthorizationServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<AuthorizationServiceRequest>;
        IDictionary<AuthorizationServiceRequest, AuthorizationServiceResponse> responses;
        IDictionary<AuthorizationServiceRequest, AuthorizationServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
        
          if (item.Key is AuthorizeRequestRequest)
          AuthorizeRequestResponse(item.Key as AuthorizeRequestRequest, item.Value as AuthorizeRequestResponse);
         }

        foreach (var item in faults) {
        
          if (item.Key is AuthorizeRequestRequest)
          AuthorizeRequestFault(item.Key as AuthorizeRequestRequest, item.Value as AuthorizeRequestFault);
         }
        }

        public void Process(
        IList<AuthorizationServiceRequest> requests,
        out IDictionary<AuthorizationServiceRequest, AuthorizationServiceResponse> responses,
        out IDictionary<AuthorizationServiceRequest, AuthorizationServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchAuthorizationServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class AuthorizationServiceClient : IAuthorizationServiceClient
        {
          public AuthorizationServiceClient(IAuthorizationService service) { Service = service; }
          public IAuthorizationService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.Logging.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Platform.V1.Messages ;
        using BigBank.Contracts.Platform.V1.Faults;
        using BigBank.Contracts.Platform.V1.Interfaces;
        using BigBank.Contracts.Platform.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Logging/V1";
      public const string XmlSchema = "http://services.bigbank.com/Logging/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Logging.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="LoggingServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class LoggingServiceRequest 
        : PlatformServiceRequest
      
      { }

      [DataContract(Name="BatchLoggingServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchLoggingServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, LoggingServiceRequest> Requests { get; set; }
      }

      
        [DataContract(Name="LogMessageRequest", Namespace=Namespaces.XmlSchema)]
        public partial class LogMessageRequest : LoggingServiceRequest { }
      

      [DataContract(Name="LoggingServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class LoggingServiceResponse  
        : PlatformServiceResponse
      
      { }

      [DataContract(Name="BatchLoggingServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchLoggingServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, LoggingServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, LoggingServiceFault> Faults { get; set; }
      }

      
        [DataContract(Name="LogMessageResponse", Namespace=Namespaces.XmlSchema)]
        public partial class LogMessageResponse : LoggingServiceResponse { }
      
      }

      namespace Faults
      {
      [DataContract(Name="LoggingServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class LoggingServiceFault 
        : PlatformServiceFault
      
      { }

      
        [DataContract(Name="LogMessageFault", Namespace=Namespaces.XmlSchema)]
        public partial class LogMessageFault : LoggingServiceFault { }
      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="LoggingService", Namespace=Namespaces.XmlService)]
        public partial interface ILoggingService
          : IPlatformService
        {
        
          [FaultContract(typeof(LogMessageFault))]
          [OperationContract(Name="LogMessage")]
          LogMessageResponse LogMessage(LogMessageRequest request);
        
        }

        [ServiceContract(Name="BatchLoggingService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchLoggingService
        {
        [FaultContract(typeof(LoggingServiceFault))]
        [OperationContract(Name="Process")]
        BatchLoggingServiceResponse Process(BatchLoggingServiceRequest request);
        }
        
        public partial interface ILoggingServiceClient
        {
          ILoggingService Service { get; set; }
        }
      }

      namespace Tests
      {
      
        [TestClass]
        public partial class LogMessageTest
        {
        private LogMessageRequest request;
        private LogMessageResponse response;
        private ILoggingService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new LogMessageRequest();
        service = new MockLoggingService();
        response = service.LogMessage(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsLogMessageResponse()
        {
        Assert.IsInstanceOfType(response, typeof(LogMessageResponse));
        }

        }
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class LoggingServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected LoggingServiceAspect(int order) { Order = order; }
          public virtual void OnPreLoggingServiceOperation(ref LoggingServiceRequest request) { }
          public virtual void OnPostLoggingServiceOperation(ref LoggingServiceRequest request, ref LoggingServiceResponse response) { }
          public virtual void OnLoggingServiceOperationError(ref LoggingServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Logging.V1.Services.MockLoggingService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Logging.V1.Services.MockLoggingService">
      <endpoint bindingNamespace="http://services.bigbank.com/Logging/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Logging.V1.Interfaces.ILoggingService"/>
      </service>
      */

      [ServiceBehavior(Name = "LoggingService", Namespace = Namespaces.XmlService)]
      public partial class MockLoggingService : LoggingServiceBase
      {
      
        public override LogMessageResponse LogMessage(LogMessageRequest request) { 
        if (request == null)
          throw new FaultException<LogMessageFault>(new LogMessageFault(), "Request was null.");
          return new LogMessageResponse(); }
      
      }
      public abstract partial class LoggingServiceBase : PlatformServiceBase,
      ILoggingService
      {
      #region Section for dealing with aspects.
      private IList<LoggingServiceAspect>   aspects = null;
      private IList<LoggingServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<LoggingServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(LoggingServiceAspect), true))
            aspects.Add((aspect as LoggingServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event LoggingServiceRequestHandler PreLoggingServiceOperation;
      public event LoggingServiceResponseHandler PostLoggingServiceOperation;
      public event LoggingServiceErrorHandler LoggingServiceOperationError;
      
        public event LogMessageRequestHandler PreLogMessage;
        public event LogMessageResponseHandler PostLogMessage;
        public event LogMessageErrorHandler LogMessageError;
      
      public delegate void LoggingServiceRequestHandler(ref LoggingServiceRequest request);
      public delegate void LoggingServiceResponseHandler(ref LoggingServiceRequest request, ref LoggingServiceResponse response);
      public delegate void LoggingServiceErrorHandler(ref LoggingServiceRequest request, ref Exception exception);
      
        public delegate void LogMessageRequestHandler(ref LogMessageRequest request);
        public delegate void LogMessageResponseHandler(ref LogMessageRequest request, ref LogMessageResponse response);
        public delegate void LogMessageErrorHandler(ref LogMessageRequest request, ref Exception exception);
      
      protected void RaisePreLoggingServiceOperation(LoggingServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreLoggingServiceOperation(ref request);
        if (PreLoggingServiceOperation != null) PreLoggingServiceOperation(ref request); }
      protected void RaisePostLoggingServiceOperation(LoggingServiceRequest request, LoggingServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostLoggingServiceOperation(ref request, ref response);
        if (PostLoggingServiceOperation != null) PostLoggingServiceOperation(ref request, ref response); }
      protected void RaiseLoggingServiceOperationError(LoggingServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnLoggingServiceOperationError(ref request, ref exception);
        if (LoggingServiceOperationError != null) LoggingServiceOperationError(ref request, ref exception); }
      
      protected void RaisePreLogMessage(LogMessageRequest request) {
        if (PreLogMessage != null) PreLogMessage(ref request); }
      protected void RaisePostLogMessage(LogMessageRequest request, LogMessageResponse response) {
        if (PostLogMessage != null) PostLogMessage(ref request, ref response); }
      protected void RaiseLogMessageError(LogMessageRequest request, Exception exception) {
        if (LogMessageError != null) LogMessageError(ref request, ref exception); }
      
        public abstract LogMessageResponse LogMessage(LogMessageRequest request);
      LogMessageResponse  ILoggingService.LogMessage(LogMessageRequest request) {
        LogMessageResponse response = null;
        try {
        
        RaisePrePlatformServiceOperation(request);
        
        RaisePreLoggingServiceOperation(request);
        RaisePreLogMessage(request);
        response = LogMessage(request);
        RaisePostLogMessage(request, response);
        RaisePostLoggingServiceOperation(request, response);
        
          RaisePostPlatformServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaisePlatformServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (LoggingServiceOperationError == null) throw;
          RaiseLoggingServiceOperationError(request, exception);
          RaiseLogMessageError(request, exception); }
        return response; }
       }
      
      public class BatchLoggingService : IBatchLoggingService
      {
      private readonly ILoggingService service;
      private readonly int maxDegreeOfParallelism;
      public BatchLoggingService(ILoggingService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchLoggingServiceResponse response = new BatchLoggingServiceResponse {
        Responses = new ConcurrentDictionary<string, LoggingServiceResponse>(),
        Faults = new ConcurrentDictionary<string, LoggingServiceFault>() };

      public BatchLoggingServiceResponse Process(BatchLoggingServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, LoggingServiceRequest> keyValuePair) {
      try
      {
      
        if (keyValuePair.Value is LogMessageRequest)
        response.Responses.Add(keyValuePair.Key, service.LogMessage(keyValuePair.Value as LogMessageRequest));
      
      }
      catch(FaultException<LoggingServiceFault> fault)
      {
      
        if (fault.Detail is LogMessageFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as LogMessageFault);
      
      }
      }
      }

      public partial class LoggingServiceProxy : ClientBase<ILoggingService>, ILoggingService
      {
      
        public LogMessageResponse LogMessage(LogMessageRequest request)
        {
        return Channel.LogMessage(request);
        }
      
      }

      public class BatchLoggingServiceProxy : ClientBase<IBatchLoggingService>, IBatchLoggingService
        {
        
          public delegate void LogMessageResponseHandler(LogMessageRequest request, LogMessageResponse response);
          public delegate void LogMessageFaultHandler(LogMessageRequest request, LogMessageFault fault);
          public event LogMessageResponseHandler LogMessageResponse;
          public event LogMessageFaultHandler LogMessageFault;
        

        public BatchLoggingServiceResponse Process(BatchLoggingServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<LoggingServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<LoggingServiceRequest>;
        IDictionary<LoggingServiceRequest, LoggingServiceResponse> responses;
        IDictionary<LoggingServiceRequest, LoggingServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
        
          if (item.Key is LogMessageRequest)
          LogMessageResponse(item.Key as LogMessageRequest, item.Value as LogMessageResponse);
         }

        foreach (var item in faults) {
        
          if (item.Key is LogMessageRequest)
          LogMessageFault(item.Key as LogMessageRequest, item.Value as LogMessageFault);
         }
        }

        public void Process(
        IList<LoggingServiceRequest> requests,
        out IDictionary<LoggingServiceRequest, LoggingServiceResponse> responses,
        out IDictionary<LoggingServiceRequest, LoggingServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchLoggingServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class LoggingServiceClient : ILoggingServiceClient
        {
          public LoggingServiceClient(ILoggingService service) { Service = service; }
          public ILoggingService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.Integration.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Base.V1.Messages ;
        using BigBank.Contracts.Base.V1.Faults;
        using BigBank.Contracts.Base.V1.Interfaces;
        using BigBank.Contracts.Base.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Integration/V1";
      public const string XmlSchema = "http://services.bigbank.com/Integration/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Integration.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="IntegrationServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class IntegrationServiceRequest 
        : BaseServiceRequest
      
      { }

      [DataContract(Name="BatchIntegrationServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchIntegrationServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, IntegrationServiceRequest> Requests { get; set; }
      }

      

      [DataContract(Name="IntegrationServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class IntegrationServiceResponse  
        : BaseServiceResponse
      
      { }

      [DataContract(Name="BatchIntegrationServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchIntegrationServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, IntegrationServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, IntegrationServiceFault> Faults { get; set; }
      }

      
      }

      namespace Faults
      {
      [DataContract(Name="IntegrationServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class IntegrationServiceFault 
        : BaseServiceFault
      
      { }

      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="IntegrationService", Namespace=Namespaces.XmlService)]
        public partial interface IIntegrationService
          : IBaseService
        {
        
        }

        [ServiceContract(Name="BatchIntegrationService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchIntegrationService
        {
        [FaultContract(typeof(IntegrationServiceFault))]
        [OperationContract(Name="Process")]
        BatchIntegrationServiceResponse Process(BatchIntegrationServiceRequest request);
        }
        
        public partial interface IIntegrationServiceClient
        {
          IIntegrationService Service { get; set; }
        }
      }

      namespace Tests
      {
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class IntegrationServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected IntegrationServiceAspect(int order) { Order = order; }
          public virtual void OnPreIntegrationServiceOperation(ref IntegrationServiceRequest request) { }
          public virtual void OnPostIntegrationServiceOperation(ref IntegrationServiceRequest request, ref IntegrationServiceResponse response) { }
          public virtual void OnIntegrationServiceOperationError(ref IntegrationServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Integration.V1.Services.MockIntegrationService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Integration.V1.Services.MockIntegrationService">
      <endpoint bindingNamespace="http://services.bigbank.com/Integration/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Integration.V1.Interfaces.IIntegrationService"/>
      </service>
      */

      [ServiceBehavior(Name = "IntegrationService", Namespace = Namespaces.XmlService)]
      public partial class MockIntegrationService : IntegrationServiceBase
      {
      
      }
      public abstract partial class IntegrationServiceBase : BaseServiceBase,
      IIntegrationService
      {
      #region Section for dealing with aspects.
      private IList<IntegrationServiceAspect>   aspects = null;
      private IList<IntegrationServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<IntegrationServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(IntegrationServiceAspect), true))
            aspects.Add((aspect as IntegrationServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event IntegrationServiceRequestHandler PreIntegrationServiceOperation;
      public event IntegrationServiceResponseHandler PostIntegrationServiceOperation;
      public event IntegrationServiceErrorHandler IntegrationServiceOperationError;
      
      public delegate void IntegrationServiceRequestHandler(ref IntegrationServiceRequest request);
      public delegate void IntegrationServiceResponseHandler(ref IntegrationServiceRequest request, ref IntegrationServiceResponse response);
      public delegate void IntegrationServiceErrorHandler(ref IntegrationServiceRequest request, ref Exception exception);
      
      protected void RaisePreIntegrationServiceOperation(IntegrationServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreIntegrationServiceOperation(ref request);
        if (PreIntegrationServiceOperation != null) PreIntegrationServiceOperation(ref request); }
      protected void RaisePostIntegrationServiceOperation(IntegrationServiceRequest request, IntegrationServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostIntegrationServiceOperation(ref request, ref response);
        if (PostIntegrationServiceOperation != null) PostIntegrationServiceOperation(ref request, ref response); }
      protected void RaiseIntegrationServiceOperationError(IntegrationServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnIntegrationServiceOperationError(ref request, ref exception);
        if (IntegrationServiceOperationError != null) IntegrationServiceOperationError(ref request, ref exception); }
       }
      
      public class BatchIntegrationService : IBatchIntegrationService
      {
      private readonly IIntegrationService service;
      private readonly int maxDegreeOfParallelism;
      public BatchIntegrationService(IIntegrationService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchIntegrationServiceResponse response = new BatchIntegrationServiceResponse {
        Responses = new ConcurrentDictionary<string, IntegrationServiceResponse>(),
        Faults = new ConcurrentDictionary<string, IntegrationServiceFault>() };

      public BatchIntegrationServiceResponse Process(BatchIntegrationServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, IntegrationServiceRequest> keyValuePair) {
      try
      {
      
      }
      catch(FaultException<IntegrationServiceFault> fault)
      {
      
      }
      }
      }

      public partial class IntegrationServiceProxy : ClientBase<IIntegrationService>, IIntegrationService
      {
      
      }

      public class BatchIntegrationServiceProxy : ClientBase<IBatchIntegrationService>, IBatchIntegrationService
        {
        

        public BatchIntegrationServiceResponse Process(BatchIntegrationServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<IntegrationServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<IntegrationServiceRequest>;
        IDictionary<IntegrationServiceRequest, IntegrationServiceResponse> responses;
        IDictionary<IntegrationServiceRequest, IntegrationServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
         }

        foreach (var item in faults) {
         }
        }

        public void Process(
        IList<IntegrationServiceRequest> requests,
        out IDictionary<IntegrationServiceRequest, IntegrationServiceResponse> responses,
        out IDictionary<IntegrationServiceRequest, IntegrationServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchIntegrationServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class IntegrationServiceClient : IIntegrationServiceClient
        {
          public IntegrationServiceClient(IIntegrationService service) { Service = service; }
          public IIntegrationService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.User.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Integration.V1.Messages ;
        using BigBank.Contracts.Integration.V1.Faults;
        using BigBank.Contracts.Integration.V1.Interfaces;
        using BigBank.Contracts.Integration.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/User/V1";
      public const string XmlSchema = "http://services.bigbank.com/User/V1#data";
      public const string ClrRoot = "BigBank.Contracts.User.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="UserServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class UserServiceRequest 
        : IntegrationServiceRequest
      
      { }

      [DataContract(Name="BatchUserServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchUserServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, UserServiceRequest> Requests { get; set; }
      }

      
        [DataContract(Name="AuthenticateUserRequest", Namespace=Namespaces.XmlSchema)]
        public partial class AuthenticateUserRequest : UserServiceRequest { }
      
        [DataContract(Name="GetUserProfileRequest", Namespace=Namespaces.XmlSchema)]
        public partial class GetUserProfileRequest : UserServiceRequest { }
      

      [DataContract(Name="UserServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class UserServiceResponse  
        : IntegrationServiceResponse
      
      { }

      [DataContract(Name="BatchUserServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchUserServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, UserServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, UserServiceFault> Faults { get; set; }
      }

      
        [DataContract(Name="AuthenticateUserResponse", Namespace=Namespaces.XmlSchema)]
        public partial class AuthenticateUserResponse : UserServiceResponse { }
      
        [DataContract(Name="GetUserProfileResponse", Namespace=Namespaces.XmlSchema)]
        public partial class GetUserProfileResponse : UserServiceResponse { }
      
      }

      namespace Faults
      {
      [DataContract(Name="UserServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class UserServiceFault 
        : IntegrationServiceFault
      
      { }

      
        [DataContract(Name="AuthenticateUserFault", Namespace=Namespaces.XmlSchema)]
        public partial class AuthenticateUserFault : UserServiceFault { }
      
        [DataContract(Name="GetUserProfileFault", Namespace=Namespaces.XmlSchema)]
        public partial class GetUserProfileFault : UserServiceFault { }
      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="UserService", Namespace=Namespaces.XmlService)]
        public partial interface IUserService
          : IIntegrationService
        {
        
          [FaultContract(typeof(AuthenticateUserFault))]
          [OperationContract(Name="AuthenticateUser")]
          AuthenticateUserResponse AuthenticateUser(AuthenticateUserRequest request);
        
          [FaultContract(typeof(GetUserProfileFault))]
          [OperationContract(Name="GetUserProfile")]
          GetUserProfileResponse GetUserProfile(GetUserProfileRequest request);
        
        }

        [ServiceContract(Name="BatchUserService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchUserService
        {
        [FaultContract(typeof(UserServiceFault))]
        [OperationContract(Name="Process")]
        BatchUserServiceResponse Process(BatchUserServiceRequest request);
        }
        
        public partial interface IUserServiceClient
        {
          IUserService Service { get; set; }
        }
      }

      namespace Tests
      {
      
        [TestClass]
        public partial class AuthenticateUserTest
        {
        private AuthenticateUserRequest request;
        private AuthenticateUserResponse response;
        private IUserService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new AuthenticateUserRequest();
        service = new MockUserService();
        response = service.AuthenticateUser(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsAuthenticateUserResponse()
        {
        Assert.IsInstanceOfType(response, typeof(AuthenticateUserResponse));
        }

        }
      
        [TestClass]
        public partial class GetUserProfileTest
        {
        private GetUserProfileRequest request;
        private GetUserProfileResponse response;
        private IUserService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new GetUserProfileRequest();
        service = new MockUserService();
        response = service.GetUserProfile(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsGetUserProfileResponse()
        {
        Assert.IsInstanceOfType(response, typeof(GetUserProfileResponse));
        }

        }
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class UserServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected UserServiceAspect(int order) { Order = order; }
          public virtual void OnPreUserServiceOperation(ref UserServiceRequest request) { }
          public virtual void OnPostUserServiceOperation(ref UserServiceRequest request, ref UserServiceResponse response) { }
          public virtual void OnUserServiceOperationError(ref UserServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.User.V1.Services.MockUserService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.User.V1.Services.MockUserService">
      <endpoint bindingNamespace="http://services.bigbank.com/User/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.User.V1.Interfaces.IUserService"/>
      </service>
      */

      [ServiceBehavior(Name = "UserService", Namespace = Namespaces.XmlService)]
      public partial class MockUserService : UserServiceBase
      {
      
        public override AuthenticateUserResponse AuthenticateUser(AuthenticateUserRequest request) { 
        if (request == null)
          throw new FaultException<AuthenticateUserFault>(new AuthenticateUserFault(), "Request was null.");
          return new AuthenticateUserResponse(); }
      
        public override GetUserProfileResponse GetUserProfile(GetUserProfileRequest request) { 
        if (request == null)
          throw new FaultException<GetUserProfileFault>(new GetUserProfileFault(), "Request was null.");
          return new GetUserProfileResponse(); }
      
      }
      public abstract partial class UserServiceBase : IntegrationServiceBase,
      IUserService
      {
      #region Section for dealing with aspects.
      private IList<UserServiceAspect>   aspects = null;
      private IList<UserServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<UserServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(UserServiceAspect), true))
            aspects.Add((aspect as UserServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event UserServiceRequestHandler PreUserServiceOperation;
      public event UserServiceResponseHandler PostUserServiceOperation;
      public event UserServiceErrorHandler UserServiceOperationError;
      
        public event AuthenticateUserRequestHandler PreAuthenticateUser;
        public event AuthenticateUserResponseHandler PostAuthenticateUser;
        public event AuthenticateUserErrorHandler AuthenticateUserError;
      
        public event GetUserProfileRequestHandler PreGetUserProfile;
        public event GetUserProfileResponseHandler PostGetUserProfile;
        public event GetUserProfileErrorHandler GetUserProfileError;
      
      public delegate void UserServiceRequestHandler(ref UserServiceRequest request);
      public delegate void UserServiceResponseHandler(ref UserServiceRequest request, ref UserServiceResponse response);
      public delegate void UserServiceErrorHandler(ref UserServiceRequest request, ref Exception exception);
      
        public delegate void AuthenticateUserRequestHandler(ref AuthenticateUserRequest request);
        public delegate void AuthenticateUserResponseHandler(ref AuthenticateUserRequest request, ref AuthenticateUserResponse response);
        public delegate void AuthenticateUserErrorHandler(ref AuthenticateUserRequest request, ref Exception exception);
      
        public delegate void GetUserProfileRequestHandler(ref GetUserProfileRequest request);
        public delegate void GetUserProfileResponseHandler(ref GetUserProfileRequest request, ref GetUserProfileResponse response);
        public delegate void GetUserProfileErrorHandler(ref GetUserProfileRequest request, ref Exception exception);
      
      protected void RaisePreUserServiceOperation(UserServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreUserServiceOperation(ref request);
        if (PreUserServiceOperation != null) PreUserServiceOperation(ref request); }
      protected void RaisePostUserServiceOperation(UserServiceRequest request, UserServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostUserServiceOperation(ref request, ref response);
        if (PostUserServiceOperation != null) PostUserServiceOperation(ref request, ref response); }
      protected void RaiseUserServiceOperationError(UserServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnUserServiceOperationError(ref request, ref exception);
        if (UserServiceOperationError != null) UserServiceOperationError(ref request, ref exception); }
      
      protected void RaisePreAuthenticateUser(AuthenticateUserRequest request) {
        if (PreAuthenticateUser != null) PreAuthenticateUser(ref request); }
      protected void RaisePostAuthenticateUser(AuthenticateUserRequest request, AuthenticateUserResponse response) {
        if (PostAuthenticateUser != null) PostAuthenticateUser(ref request, ref response); }
      protected void RaiseAuthenticateUserError(AuthenticateUserRequest request, Exception exception) {
        if (AuthenticateUserError != null) AuthenticateUserError(ref request, ref exception); }
      
      protected void RaisePreGetUserProfile(GetUserProfileRequest request) {
        if (PreGetUserProfile != null) PreGetUserProfile(ref request); }
      protected void RaisePostGetUserProfile(GetUserProfileRequest request, GetUserProfileResponse response) {
        if (PostGetUserProfile != null) PostGetUserProfile(ref request, ref response); }
      protected void RaiseGetUserProfileError(GetUserProfileRequest request, Exception exception) {
        if (GetUserProfileError != null) GetUserProfileError(ref request, ref exception); }
      
        public abstract AuthenticateUserResponse AuthenticateUser(AuthenticateUserRequest request);
      
        public abstract GetUserProfileResponse GetUserProfile(GetUserProfileRequest request);
      AuthenticateUserResponse  IUserService.AuthenticateUser(AuthenticateUserRequest request) {
        AuthenticateUserResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreUserServiceOperation(request);
        RaisePreAuthenticateUser(request);
        response = AuthenticateUser(request);
        RaisePostAuthenticateUser(request, response);
        RaisePostUserServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (UserServiceOperationError == null) throw;
          RaiseUserServiceOperationError(request, exception);
          RaiseAuthenticateUserError(request, exception); }
        return response; }
      GetUserProfileResponse  IUserService.GetUserProfile(GetUserProfileRequest request) {
        GetUserProfileResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreUserServiceOperation(request);
        RaisePreGetUserProfile(request);
        response = GetUserProfile(request);
        RaisePostGetUserProfile(request, response);
        RaisePostUserServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (UserServiceOperationError == null) throw;
          RaiseUserServiceOperationError(request, exception);
          RaiseGetUserProfileError(request, exception); }
        return response; }
       }
      
      public class BatchUserService : IBatchUserService
      {
      private readonly IUserService service;
      private readonly int maxDegreeOfParallelism;
      public BatchUserService(IUserService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchUserServiceResponse response = new BatchUserServiceResponse {
        Responses = new ConcurrentDictionary<string, UserServiceResponse>(),
        Faults = new ConcurrentDictionary<string, UserServiceFault>() };

      public BatchUserServiceResponse Process(BatchUserServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, UserServiceRequest> keyValuePair) {
      try
      {
      
        if (keyValuePair.Value is AuthenticateUserRequest)
        response.Responses.Add(keyValuePair.Key, service.AuthenticateUser(keyValuePair.Value as AuthenticateUserRequest));
      
        if (keyValuePair.Value is GetUserProfileRequest)
        response.Responses.Add(keyValuePair.Key, service.GetUserProfile(keyValuePair.Value as GetUserProfileRequest));
      
      }
      catch(FaultException<UserServiceFault> fault)
      {
      
        if (fault.Detail is AuthenticateUserFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as AuthenticateUserFault);
      
        if (fault.Detail is GetUserProfileFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as GetUserProfileFault);
      
      }
      }
      }

      public partial class UserServiceProxy : ClientBase<IUserService>, IUserService
      {
      
        public AuthenticateUserResponse AuthenticateUser(AuthenticateUserRequest request)
        {
        return Channel.AuthenticateUser(request);
        }
      
        public GetUserProfileResponse GetUserProfile(GetUserProfileRequest request)
        {
        return Channel.GetUserProfile(request);
        }
      
      }

      public class BatchUserServiceProxy : ClientBase<IBatchUserService>, IBatchUserService
        {
        
          public delegate void AuthenticateUserResponseHandler(AuthenticateUserRequest request, AuthenticateUserResponse response);
          public delegate void AuthenticateUserFaultHandler(AuthenticateUserRequest request, AuthenticateUserFault fault);
          public event AuthenticateUserResponseHandler AuthenticateUserResponse;
          public event AuthenticateUserFaultHandler AuthenticateUserFault;
        
          public delegate void GetUserProfileResponseHandler(GetUserProfileRequest request, GetUserProfileResponse response);
          public delegate void GetUserProfileFaultHandler(GetUserProfileRequest request, GetUserProfileFault fault);
          public event GetUserProfileResponseHandler GetUserProfileResponse;
          public event GetUserProfileFaultHandler GetUserProfileFault;
        

        public BatchUserServiceResponse Process(BatchUserServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<UserServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<UserServiceRequest>;
        IDictionary<UserServiceRequest, UserServiceResponse> responses;
        IDictionary<UserServiceRequest, UserServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
        
          if (item.Key is AuthenticateUserRequest)
          AuthenticateUserResponse(item.Key as AuthenticateUserRequest, item.Value as AuthenticateUserResponse);
        
          if (item.Key is GetUserProfileRequest)
          GetUserProfileResponse(item.Key as GetUserProfileRequest, item.Value as GetUserProfileResponse);
         }

        foreach (var item in faults) {
        
          if (item.Key is AuthenticateUserRequest)
          AuthenticateUserFault(item.Key as AuthenticateUserRequest, item.Value as AuthenticateUserFault);
        
          if (item.Key is GetUserProfileRequest)
          GetUserProfileFault(item.Key as GetUserProfileRequest, item.Value as GetUserProfileFault);
         }
        }

        public void Process(
        IList<UserServiceRequest> requests,
        out IDictionary<UserServiceRequest, UserServiceResponse> responses,
        out IDictionary<UserServiceRequest, UserServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchUserServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class UserServiceClient : IUserServiceClient
        {
          public UserServiceClient(IUserService service) { Service = service; }
          public IUserService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.Banking.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Integration.V1.Messages ;
        using BigBank.Contracts.Integration.V1.Faults;
        using BigBank.Contracts.Integration.V1.Interfaces;
        using BigBank.Contracts.Integration.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/Banking/V1";
      public const string XmlSchema = "http://services.bigbank.com/Banking/V1#data";
      public const string ClrRoot = "BigBank.Contracts.Banking.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="BankingServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BankingServiceRequest 
        : IntegrationServiceRequest
      
      { }

      [DataContract(Name="BatchBankingServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBankingServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, BankingServiceRequest> Requests { get; set; }
      }

      
        [DataContract(Name="GetAccountsRequest", Namespace=Namespaces.XmlSchema)]
        public partial class GetAccountsRequest : BankingServiceRequest { }
      
        [DataContract(Name="ProcessTransferRequest", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessTransferRequest : BankingServiceRequest { }
      
        [DataContract(Name="SearchHistoryRequest", Namespace=Namespaces.XmlSchema)]
        public partial class SearchHistoryRequest : BankingServiceRequest { }
      

      [DataContract(Name="BankingServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BankingServiceResponse  
        : IntegrationServiceResponse
      
      { }

      [DataContract(Name="BatchBankingServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBankingServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, BankingServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, BankingServiceFault> Faults { get; set; }
      }

      
        [DataContract(Name="GetAccountsResponse", Namespace=Namespaces.XmlSchema)]
        public partial class GetAccountsResponse : BankingServiceResponse { }
      
        [DataContract(Name="ProcessTransferResponse", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessTransferResponse : BankingServiceResponse { }
      
        [DataContract(Name="SearchHistoryResponse", Namespace=Namespaces.XmlSchema)]
        public partial class SearchHistoryResponse : BankingServiceResponse { }
      
      }

      namespace Faults
      {
      [DataContract(Name="BankingServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class BankingServiceFault 
        : IntegrationServiceFault
      
      { }

      
        [DataContract(Name="GetAccountsFault", Namespace=Namespaces.XmlSchema)]
        public partial class GetAccountsFault : BankingServiceFault { }
      
        [DataContract(Name="ProcessTransferFault", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessTransferFault : BankingServiceFault { }
      
        [DataContract(Name="SearchHistoryFault", Namespace=Namespaces.XmlSchema)]
        public partial class SearchHistoryFault : BankingServiceFault { }
      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="BankingService", Namespace=Namespaces.XmlService)]
        public partial interface IBankingService
          : IIntegrationService
        {
        
          [FaultContract(typeof(GetAccountsFault))]
          [OperationContract(Name="GetAccounts")]
          GetAccountsResponse GetAccounts(GetAccountsRequest request);
        
          [FaultContract(typeof(ProcessTransferFault))]
          [OperationContract(Name="ProcessTransfer")]
          ProcessTransferResponse ProcessTransfer(ProcessTransferRequest request);
        
          [FaultContract(typeof(SearchHistoryFault))]
          [OperationContract(Name="SearchHistory")]
          SearchHistoryResponse SearchHistory(SearchHistoryRequest request);
        
        }

        [ServiceContract(Name="BatchBankingService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchBankingService
        {
        [FaultContract(typeof(BankingServiceFault))]
        [OperationContract(Name="Process")]
        BatchBankingServiceResponse Process(BatchBankingServiceRequest request);
        }
        
        public partial interface IBankingServiceClient
        {
          IBankingService Service { get; set; }
        }
      }

      namespace Tests
      {
      
        [TestClass]
        public partial class GetAccountsTest
        {
        private GetAccountsRequest request;
        private GetAccountsResponse response;
        private IBankingService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new GetAccountsRequest();
        service = new MockBankingService();
        response = service.GetAccounts(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsGetAccountsResponse()
        {
        Assert.IsInstanceOfType(response, typeof(GetAccountsResponse));
        }

        }
      
        [TestClass]
        public partial class ProcessTransferTest
        {
        private ProcessTransferRequest request;
        private ProcessTransferResponse response;
        private IBankingService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new ProcessTransferRequest();
        service = new MockBankingService();
        response = service.ProcessTransfer(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsProcessTransferResponse()
        {
        Assert.IsInstanceOfType(response, typeof(ProcessTransferResponse));
        }

        }
      
        [TestClass]
        public partial class SearchHistoryTest
        {
        private SearchHistoryRequest request;
        private SearchHistoryResponse response;
        private IBankingService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new SearchHistoryRequest();
        service = new MockBankingService();
        response = service.SearchHistory(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsSearchHistoryResponse()
        {
        Assert.IsInstanceOfType(response, typeof(SearchHistoryResponse));
        }

        }
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class BankingServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected BankingServiceAspect(int order) { Order = order; }
          public virtual void OnPreBankingServiceOperation(ref BankingServiceRequest request) { }
          public virtual void OnPostBankingServiceOperation(ref BankingServiceRequest request, ref BankingServiceResponse response) { }
          public virtual void OnBankingServiceOperationError(ref BankingServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.Banking.V1.Services.MockBankingService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.Banking.V1.Services.MockBankingService">
      <endpoint bindingNamespace="http://services.bigbank.com/Banking/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.Banking.V1.Interfaces.IBankingService"/>
      </service>
      */

      [ServiceBehavior(Name = "BankingService", Namespace = Namespaces.XmlService)]
      public partial class MockBankingService : BankingServiceBase
      {
      
        public override GetAccountsResponse GetAccounts(GetAccountsRequest request) { 
        if (request == null)
          throw new FaultException<GetAccountsFault>(new GetAccountsFault(), "Request was null.");
          return new GetAccountsResponse(); }
      
        public override ProcessTransferResponse ProcessTransfer(ProcessTransferRequest request) { 
        if (request == null)
          throw new FaultException<ProcessTransferFault>(new ProcessTransferFault(), "Request was null.");
          return new ProcessTransferResponse(); }
      
        public override SearchHistoryResponse SearchHistory(SearchHistoryRequest request) { 
        if (request == null)
          throw new FaultException<SearchHistoryFault>(new SearchHistoryFault(), "Request was null.");
          return new SearchHistoryResponse(); }
      
      }
      public abstract partial class BankingServiceBase : IntegrationServiceBase,
      IBankingService
      {
      #region Section for dealing with aspects.
      private IList<BankingServiceAspect>   aspects = null;
      private IList<BankingServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<BankingServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(BankingServiceAspect), true))
            aspects.Add((aspect as BankingServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event BankingServiceRequestHandler PreBankingServiceOperation;
      public event BankingServiceResponseHandler PostBankingServiceOperation;
      public event BankingServiceErrorHandler BankingServiceOperationError;
      
        public event GetAccountsRequestHandler PreGetAccounts;
        public event GetAccountsResponseHandler PostGetAccounts;
        public event GetAccountsErrorHandler GetAccountsError;
      
        public event ProcessTransferRequestHandler PreProcessTransfer;
        public event ProcessTransferResponseHandler PostProcessTransfer;
        public event ProcessTransferErrorHandler ProcessTransferError;
      
        public event SearchHistoryRequestHandler PreSearchHistory;
        public event SearchHistoryResponseHandler PostSearchHistory;
        public event SearchHistoryErrorHandler SearchHistoryError;
      
      public delegate void BankingServiceRequestHandler(ref BankingServiceRequest request);
      public delegate void BankingServiceResponseHandler(ref BankingServiceRequest request, ref BankingServiceResponse response);
      public delegate void BankingServiceErrorHandler(ref BankingServiceRequest request, ref Exception exception);
      
        public delegate void GetAccountsRequestHandler(ref GetAccountsRequest request);
        public delegate void GetAccountsResponseHandler(ref GetAccountsRequest request, ref GetAccountsResponse response);
        public delegate void GetAccountsErrorHandler(ref GetAccountsRequest request, ref Exception exception);
      
        public delegate void ProcessTransferRequestHandler(ref ProcessTransferRequest request);
        public delegate void ProcessTransferResponseHandler(ref ProcessTransferRequest request, ref ProcessTransferResponse response);
        public delegate void ProcessTransferErrorHandler(ref ProcessTransferRequest request, ref Exception exception);
      
        public delegate void SearchHistoryRequestHandler(ref SearchHistoryRequest request);
        public delegate void SearchHistoryResponseHandler(ref SearchHistoryRequest request, ref SearchHistoryResponse response);
        public delegate void SearchHistoryErrorHandler(ref SearchHistoryRequest request, ref Exception exception);
      
      protected void RaisePreBankingServiceOperation(BankingServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreBankingServiceOperation(ref request);
        if (PreBankingServiceOperation != null) PreBankingServiceOperation(ref request); }
      protected void RaisePostBankingServiceOperation(BankingServiceRequest request, BankingServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostBankingServiceOperation(ref request, ref response);
        if (PostBankingServiceOperation != null) PostBankingServiceOperation(ref request, ref response); }
      protected void RaiseBankingServiceOperationError(BankingServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnBankingServiceOperationError(ref request, ref exception);
        if (BankingServiceOperationError != null) BankingServiceOperationError(ref request, ref exception); }
      
      protected void RaisePreGetAccounts(GetAccountsRequest request) {
        if (PreGetAccounts != null) PreGetAccounts(ref request); }
      protected void RaisePostGetAccounts(GetAccountsRequest request, GetAccountsResponse response) {
        if (PostGetAccounts != null) PostGetAccounts(ref request, ref response); }
      protected void RaiseGetAccountsError(GetAccountsRequest request, Exception exception) {
        if (GetAccountsError != null) GetAccountsError(ref request, ref exception); }
      
      protected void RaisePreProcessTransfer(ProcessTransferRequest request) {
        if (PreProcessTransfer != null) PreProcessTransfer(ref request); }
      protected void RaisePostProcessTransfer(ProcessTransferRequest request, ProcessTransferResponse response) {
        if (PostProcessTransfer != null) PostProcessTransfer(ref request, ref response); }
      protected void RaiseProcessTransferError(ProcessTransferRequest request, Exception exception) {
        if (ProcessTransferError != null) ProcessTransferError(ref request, ref exception); }
      
      protected void RaisePreSearchHistory(SearchHistoryRequest request) {
        if (PreSearchHistory != null) PreSearchHistory(ref request); }
      protected void RaisePostSearchHistory(SearchHistoryRequest request, SearchHistoryResponse response) {
        if (PostSearchHistory != null) PostSearchHistory(ref request, ref response); }
      protected void RaiseSearchHistoryError(SearchHistoryRequest request, Exception exception) {
        if (SearchHistoryError != null) SearchHistoryError(ref request, ref exception); }
      
        public abstract GetAccountsResponse GetAccounts(GetAccountsRequest request);
      
        public abstract ProcessTransferResponse ProcessTransfer(ProcessTransferRequest request);
      
        public abstract SearchHistoryResponse SearchHistory(SearchHistoryRequest request);
      GetAccountsResponse  IBankingService.GetAccounts(GetAccountsRequest request) {
        GetAccountsResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBankingServiceOperation(request);
        RaisePreGetAccounts(request);
        response = GetAccounts(request);
        RaisePostGetAccounts(request, response);
        RaisePostBankingServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BankingServiceOperationError == null) throw;
          RaiseBankingServiceOperationError(request, exception);
          RaiseGetAccountsError(request, exception); }
        return response; }
      ProcessTransferResponse  IBankingService.ProcessTransfer(ProcessTransferRequest request) {
        ProcessTransferResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBankingServiceOperation(request);
        RaisePreProcessTransfer(request);
        response = ProcessTransfer(request);
        RaisePostProcessTransfer(request, response);
        RaisePostBankingServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BankingServiceOperationError == null) throw;
          RaiseBankingServiceOperationError(request, exception);
          RaiseProcessTransferError(request, exception); }
        return response; }
      SearchHistoryResponse  IBankingService.SearchHistory(SearchHistoryRequest request) {
        SearchHistoryResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBankingServiceOperation(request);
        RaisePreSearchHistory(request);
        response = SearchHistory(request);
        RaisePostSearchHistory(request, response);
        RaisePostBankingServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BankingServiceOperationError == null) throw;
          RaiseBankingServiceOperationError(request, exception);
          RaiseSearchHistoryError(request, exception); }
        return response; }
       }
      
      public class BatchBankingService : IBatchBankingService
      {
      private readonly IBankingService service;
      private readonly int maxDegreeOfParallelism;
      public BatchBankingService(IBankingService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchBankingServiceResponse response = new BatchBankingServiceResponse {
        Responses = new ConcurrentDictionary<string, BankingServiceResponse>(),
        Faults = new ConcurrentDictionary<string, BankingServiceFault>() };

      public BatchBankingServiceResponse Process(BatchBankingServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, BankingServiceRequest> keyValuePair) {
      try
      {
      
        if (keyValuePair.Value is GetAccountsRequest)
        response.Responses.Add(keyValuePair.Key, service.GetAccounts(keyValuePair.Value as GetAccountsRequest));
      
        if (keyValuePair.Value is ProcessTransferRequest)
        response.Responses.Add(keyValuePair.Key, service.ProcessTransfer(keyValuePair.Value as ProcessTransferRequest));
      
        if (keyValuePair.Value is SearchHistoryRequest)
        response.Responses.Add(keyValuePair.Key, service.SearchHistory(keyValuePair.Value as SearchHistoryRequest));
      
      }
      catch(FaultException<BankingServiceFault> fault)
      {
      
        if (fault.Detail is GetAccountsFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as GetAccountsFault);
      
        if (fault.Detail is ProcessTransferFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as ProcessTransferFault);
      
        if (fault.Detail is SearchHistoryFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as SearchHistoryFault);
      
      }
      }
      }

      public partial class BankingServiceProxy : ClientBase<IBankingService>, IBankingService
      {
      
        public GetAccountsResponse GetAccounts(GetAccountsRequest request)
        {
        return Channel.GetAccounts(request);
        }
      
        public ProcessTransferResponse ProcessTransfer(ProcessTransferRequest request)
        {
        return Channel.ProcessTransfer(request);
        }
      
        public SearchHistoryResponse SearchHistory(SearchHistoryRequest request)
        {
        return Channel.SearchHistory(request);
        }
      
      }

      public class BatchBankingServiceProxy : ClientBase<IBatchBankingService>, IBatchBankingService
        {
        
          public delegate void GetAccountsResponseHandler(GetAccountsRequest request, GetAccountsResponse response);
          public delegate void GetAccountsFaultHandler(GetAccountsRequest request, GetAccountsFault fault);
          public event GetAccountsResponseHandler GetAccountsResponse;
          public event GetAccountsFaultHandler GetAccountsFault;
        
          public delegate void ProcessTransferResponseHandler(ProcessTransferRequest request, ProcessTransferResponse response);
          public delegate void ProcessTransferFaultHandler(ProcessTransferRequest request, ProcessTransferFault fault);
          public event ProcessTransferResponseHandler ProcessTransferResponse;
          public event ProcessTransferFaultHandler ProcessTransferFault;
        
          public delegate void SearchHistoryResponseHandler(SearchHistoryRequest request, SearchHistoryResponse response);
          public delegate void SearchHistoryFaultHandler(SearchHistoryRequest request, SearchHistoryFault fault);
          public event SearchHistoryResponseHandler SearchHistoryResponse;
          public event SearchHistoryFaultHandler SearchHistoryFault;
        

        public BatchBankingServiceResponse Process(BatchBankingServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<BankingServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<BankingServiceRequest>;
        IDictionary<BankingServiceRequest, BankingServiceResponse> responses;
        IDictionary<BankingServiceRequest, BankingServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
        
          if (item.Key is GetAccountsRequest)
          GetAccountsResponse(item.Key as GetAccountsRequest, item.Value as GetAccountsResponse);
        
          if (item.Key is ProcessTransferRequest)
          ProcessTransferResponse(item.Key as ProcessTransferRequest, item.Value as ProcessTransferResponse);
        
          if (item.Key is SearchHistoryRequest)
          SearchHistoryResponse(item.Key as SearchHistoryRequest, item.Value as SearchHistoryResponse);
         }

        foreach (var item in faults) {
        
          if (item.Key is GetAccountsRequest)
          GetAccountsFault(item.Key as GetAccountsRequest, item.Value as GetAccountsFault);
        
          if (item.Key is ProcessTransferRequest)
          ProcessTransferFault(item.Key as ProcessTransferRequest, item.Value as ProcessTransferFault);
        
          if (item.Key is SearchHistoryRequest)
          SearchHistoryFault(item.Key as SearchHistoryRequest, item.Value as SearchHistoryFault);
         }
        }

        public void Process(
        IList<BankingServiceRequest> requests,
        out IDictionary<BankingServiceRequest, BankingServiceResponse> responses,
        out IDictionary<BankingServiceRequest, BankingServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchBankingServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class BankingServiceClient : IBankingServiceClient
        {
          public BankingServiceClient(IBankingService service) { Service = service; }
          public IBankingService Service { get; set; }
        }
    }
  }
    
      namespace BigBank.Contracts.BillPayment.V1
      {
      using Messages;
      using Faults;
      using Interfaces;
      using Services;
      using Aspects;
        using BigBank.Contracts.Integration.V1.Messages ;
        using BigBank.Contracts.Integration.V1.Faults;
        using BigBank.Contracts.Integration.V1.Interfaces;
        using BigBank.Contracts.Integration.V1.Services;
      

      public static class Namespaces
      {
      public const string XmlService = "http://services.bigbank.com/BillPayment/V1";
      public const string XmlSchema = "http://services.bigbank.com/BillPayment/V1#data";
      public const string ClrRoot = "BigBank.Contracts.BillPayment.V1";
      public const string ClrModels = ClrRoot + ".Models";
      public const string ClrMessages = ClrRoot + ".Messages";
      }

      namespace Messages
      {

      [DataContract(Name="BillPaymentServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BillPaymentServiceRequest 
        : IntegrationServiceRequest
      
      { }

      [DataContract(Name="BatchBillPaymentServiceRequest", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBillPaymentServiceRequest
      {
      [DataMember(Name="Requests", IsRequired=true)]
      public IDictionary<string, BillPaymentServiceRequest> Requests { get; set; }
      }

      
        [DataContract(Name="GetPayeesRequest", Namespace=Namespaces.XmlSchema)]
        public partial class GetPayeesRequest : BillPaymentServiceRequest { }
      
        [DataContract(Name="ProcessPaymentRequest", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessPaymentRequest : BillPaymentServiceRequest { }
      
        [DataContract(Name="SearchPaymentHistoryRequest", Namespace=Namespaces.XmlSchema)]
        public partial class SearchPaymentHistoryRequest : BillPaymentServiceRequest { }
      
        [DataContract(Name="AddPayeeRequest", Namespace=Namespaces.XmlSchema)]
        public partial class AddPayeeRequest : BillPaymentServiceRequest { }
      

      [DataContract(Name="BillPaymentServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BillPaymentServiceResponse  
        : IntegrationServiceResponse
      
      { }

      [DataContract(Name="BatchBillPaymentServiceResponse", Namespace=Namespaces.XmlSchema)]
      public partial class BatchBillPaymentServiceResponse
      {
      [DataMember(Name="Responses", IsRequired=true)]
      public IDictionary<string, BillPaymentServiceResponse> Responses { get; set; }

      [DataMember(Name="Faults", IsRequired=true)]
      public IDictionary<string, BillPaymentServiceFault> Faults { get; set; }
      }

      
        [DataContract(Name="GetPayeesResponse", Namespace=Namespaces.XmlSchema)]
        public partial class GetPayeesResponse : BillPaymentServiceResponse { }
      
        [DataContract(Name="ProcessPaymentResponse", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessPaymentResponse : BillPaymentServiceResponse { }
      
        [DataContract(Name="SearchPaymentHistoryResponse", Namespace=Namespaces.XmlSchema)]
        public partial class SearchPaymentHistoryResponse : BillPaymentServiceResponse { }
      
        [DataContract(Name="AddPayeeResponse", Namespace=Namespaces.XmlSchema)]
        public partial class AddPayeeResponse : BillPaymentServiceResponse { }
      
      }

      namespace Faults
      {
      [DataContract(Name="BillPaymentServiceFault", Namespace=Namespaces.XmlSchema)]
      public partial class BillPaymentServiceFault 
        : IntegrationServiceFault
      
      { }

      
        [DataContract(Name="GetPayeesFault", Namespace=Namespaces.XmlSchema)]
        public partial class GetPayeesFault : BillPaymentServiceFault { }
      
        [DataContract(Name="ProcessPaymentFault", Namespace=Namespaces.XmlSchema)]
        public partial class ProcessPaymentFault : BillPaymentServiceFault { }
      
        [DataContract(Name="SearchPaymentHistoryFault", Namespace=Namespaces.XmlSchema)]
        public partial class SearchPaymentHistoryFault : BillPaymentServiceFault { }
      
        [DataContract(Name="AddPayeeFault", Namespace=Namespaces.XmlSchema)]
        public partial class AddPayeeFault : BillPaymentServiceFault { }
      
      }

      namespace Interfaces
      {
        
        [ServiceContract(Name="BillPaymentService", Namespace=Namespaces.XmlService)]
        public partial interface IBillPaymentService
          : IIntegrationService
        {
        
          [FaultContract(typeof(GetPayeesFault))]
          [OperationContract(Name="GetPayees")]
          GetPayeesResponse GetPayees(GetPayeesRequest request);
        
          [FaultContract(typeof(ProcessPaymentFault))]
          [OperationContract(Name="ProcessPayment")]
          ProcessPaymentResponse ProcessPayment(ProcessPaymentRequest request);
        
          [FaultContract(typeof(SearchPaymentHistoryFault))]
          [OperationContract(Name="SearchPaymentHistory")]
          SearchPaymentHistoryResponse SearchPaymentHistory(SearchPaymentHistoryRequest request);
        
          [FaultContract(typeof(AddPayeeFault))]
          [OperationContract(Name="AddPayee")]
          AddPayeeResponse AddPayee(AddPayeeRequest request);
        
        }

        [ServiceContract(Name="BatchBillPaymentService", Namespace=Namespaces.XmlService)]
        public partial interface IBatchBillPaymentService
        {
        [FaultContract(typeof(BillPaymentServiceFault))]
        [OperationContract(Name="Process")]
        BatchBillPaymentServiceResponse Process(BatchBillPaymentServiceRequest request);
        }
        
        public partial interface IBillPaymentServiceClient
        {
          IBillPaymentService Service { get; set; }
        }
      }

      namespace Tests
      {
      
        [TestClass]
        public partial class GetPayeesTest
        {
        private GetPayeesRequest request;
        private GetPayeesResponse response;
        private IBillPaymentService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new GetPayeesRequest();
        service = new MockBillPaymentService();
        response = service.GetPayees(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsGetPayeesResponse()
        {
        Assert.IsInstanceOfType(response, typeof(GetPayeesResponse));
        }

        }
      
        [TestClass]
        public partial class ProcessPaymentTest
        {
        private ProcessPaymentRequest request;
        private ProcessPaymentResponse response;
        private IBillPaymentService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new ProcessPaymentRequest();
        service = new MockBillPaymentService();
        response = service.ProcessPayment(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsProcessPaymentResponse()
        {
        Assert.IsInstanceOfType(response, typeof(ProcessPaymentResponse));
        }

        }
      
        [TestClass]
        public partial class SearchPaymentHistoryTest
        {
        private SearchPaymentHistoryRequest request;
        private SearchPaymentHistoryResponse response;
        private IBillPaymentService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new SearchPaymentHistoryRequest();
        service = new MockBillPaymentService();
        response = service.SearchPaymentHistory(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsSearchPaymentHistoryResponse()
        {
        Assert.IsInstanceOfType(response, typeof(SearchPaymentHistoryResponse));
        }

        }
      
        [TestClass]
        public partial class AddPayeeTest
        {
        private AddPayeeRequest request;
        private AddPayeeResponse response;
        private IBillPaymentService service;

        [TestInitialize]
        public void TestInitialize()
        {
        request = new AddPayeeRequest();
        service = new MockBillPaymentService();
        response = service.AddPayee(request);
        }

        [TestMethod]
        public void ResponseIsNotNull()
        {
        Assert.IsNotNull(response);
        }

        [TestMethod]
        public void ResponseTypeIsAddPayeeResponse()
        {
        Assert.IsInstanceOfType(response, typeof(AddPayeeResponse));
        }

        }
      
      }

      namespace Aspects
      {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public abstract class BillPaymentServiceAspect : Attribute
        {
          public int Order { get; set; }
          protected BillPaymentServiceAspect(int order) { Order = order; }
          public virtual void OnPreBillPaymentServiceOperation(ref BillPaymentServiceRequest request) { }
          public virtual void OnPostBillPaymentServiceOperation(ref BillPaymentServiceRequest request, ref BillPaymentServiceResponse response) { }
          public virtual void OnBillPaymentServiceOperationError(ref BillPaymentServiceRequest request, ref Exception exception) { }
        } 
      }

      namespace Services
      {

      /*

      For .svc file:

      <%@ ServiceHost Language="C#" Debug="true" Service="BigBank.Contracts.BillPayment.V1.Services.MockBillPaymentService" %>

      For web.config, serviceModel section:

      <service name="BigBank.Contracts.BillPayment.V1.Services.MockBillPaymentService">
      <endpoint bindingNamespace="http://services.bigbank.com/BillPayment/V1"
      binding="basicHttpBinding"
      contract="BigBank.Contracts.BillPayment.V1.Interfaces.IBillPaymentService"/>
      </service>
      */

      [ServiceBehavior(Name = "BillPaymentService", Namespace = Namespaces.XmlService)]
      public partial class MockBillPaymentService : BillPaymentServiceBase
      {
      
        public override GetPayeesResponse GetPayees(GetPayeesRequest request) { 
        if (request == null)
          throw new FaultException<GetPayeesFault>(new GetPayeesFault(), "Request was null.");
          return new GetPayeesResponse(); }
      
        public override ProcessPaymentResponse ProcessPayment(ProcessPaymentRequest request) { 
        if (request == null)
          throw new FaultException<ProcessPaymentFault>(new ProcessPaymentFault(), "Request was null.");
          return new ProcessPaymentResponse(); }
      
        public override SearchPaymentHistoryResponse SearchPaymentHistory(SearchPaymentHistoryRequest request) { 
        if (request == null)
          throw new FaultException<SearchPaymentHistoryFault>(new SearchPaymentHistoryFault(), "Request was null.");
          return new SearchPaymentHistoryResponse(); }
      
        public override AddPayeeResponse AddPayee(AddPayeeRequest request) { 
        if (request == null)
          throw new FaultException<AddPayeeFault>(new AddPayeeFault(), "Request was null.");
          return new AddPayeeResponse(); }
      
      }
      public abstract partial class BillPaymentServiceBase : IntegrationServiceBase,
      IBillPaymentService
      {
      #region Section for dealing with aspects.
      private IList<BillPaymentServiceAspect>   aspects = null;
      private IList<BillPaymentServiceAspect>
      Aspects
      {
        get {
          if (aspects == null)
          {
            aspects = new List<BillPaymentServiceAspect>();
            foreach (var aspect in GetType().GetCustomAttributes(typeof(BillPaymentServiceAspect), true))
            aspects.Add((aspect as BillPaymentServiceAspect));
          }
          return aspects.OrderBy(a=>a.Order).ToList(); 
        }
      }
      #endregion
      public event BillPaymentServiceRequestHandler PreBillPaymentServiceOperation;
      public event BillPaymentServiceResponseHandler PostBillPaymentServiceOperation;
      public event BillPaymentServiceErrorHandler BillPaymentServiceOperationError;
      
        public event GetPayeesRequestHandler PreGetPayees;
        public event GetPayeesResponseHandler PostGetPayees;
        public event GetPayeesErrorHandler GetPayeesError;
      
        public event ProcessPaymentRequestHandler PreProcessPayment;
        public event ProcessPaymentResponseHandler PostProcessPayment;
        public event ProcessPaymentErrorHandler ProcessPaymentError;
      
        public event SearchPaymentHistoryRequestHandler PreSearchPaymentHistory;
        public event SearchPaymentHistoryResponseHandler PostSearchPaymentHistory;
        public event SearchPaymentHistoryErrorHandler SearchPaymentHistoryError;
      
        public event AddPayeeRequestHandler PreAddPayee;
        public event AddPayeeResponseHandler PostAddPayee;
        public event AddPayeeErrorHandler AddPayeeError;
      
      public delegate void BillPaymentServiceRequestHandler(ref BillPaymentServiceRequest request);
      public delegate void BillPaymentServiceResponseHandler(ref BillPaymentServiceRequest request, ref BillPaymentServiceResponse response);
      public delegate void BillPaymentServiceErrorHandler(ref BillPaymentServiceRequest request, ref Exception exception);
      
        public delegate void GetPayeesRequestHandler(ref GetPayeesRequest request);
        public delegate void GetPayeesResponseHandler(ref GetPayeesRequest request, ref GetPayeesResponse response);
        public delegate void GetPayeesErrorHandler(ref GetPayeesRequest request, ref Exception exception);
      
        public delegate void ProcessPaymentRequestHandler(ref ProcessPaymentRequest request);
        public delegate void ProcessPaymentResponseHandler(ref ProcessPaymentRequest request, ref ProcessPaymentResponse response);
        public delegate void ProcessPaymentErrorHandler(ref ProcessPaymentRequest request, ref Exception exception);
      
        public delegate void SearchPaymentHistoryRequestHandler(ref SearchPaymentHistoryRequest request);
        public delegate void SearchPaymentHistoryResponseHandler(ref SearchPaymentHistoryRequest request, ref SearchPaymentHistoryResponse response);
        public delegate void SearchPaymentHistoryErrorHandler(ref SearchPaymentHistoryRequest request, ref Exception exception);
      
        public delegate void AddPayeeRequestHandler(ref AddPayeeRequest request);
        public delegate void AddPayeeResponseHandler(ref AddPayeeRequest request, ref AddPayeeResponse response);
        public delegate void AddPayeeErrorHandler(ref AddPayeeRequest request, ref Exception exception);
      
      protected void RaisePreBillPaymentServiceOperation(BillPaymentServiceRequest request) {
        foreach (var aspect in Aspects)
        aspect.OnPreBillPaymentServiceOperation(ref request);
        if (PreBillPaymentServiceOperation != null) PreBillPaymentServiceOperation(ref request); }
      protected void RaisePostBillPaymentServiceOperation(BillPaymentServiceRequest request, BillPaymentServiceResponse response) {
        foreach (var aspect in Aspects)
        aspect.OnPostBillPaymentServiceOperation(ref request, ref response);
        if (PostBillPaymentServiceOperation != null) PostBillPaymentServiceOperation(ref request, ref response); }
      protected void RaiseBillPaymentServiceOperationError(BillPaymentServiceRequest request, Exception exception) {
        foreach (var aspect in Aspects)
        aspect.OnBillPaymentServiceOperationError(ref request, ref exception);
        if (BillPaymentServiceOperationError != null) BillPaymentServiceOperationError(ref request, ref exception); }
      
      protected void RaisePreGetPayees(GetPayeesRequest request) {
        if (PreGetPayees != null) PreGetPayees(ref request); }
      protected void RaisePostGetPayees(GetPayeesRequest request, GetPayeesResponse response) {
        if (PostGetPayees != null) PostGetPayees(ref request, ref response); }
      protected void RaiseGetPayeesError(GetPayeesRequest request, Exception exception) {
        if (GetPayeesError != null) GetPayeesError(ref request, ref exception); }
      
      protected void RaisePreProcessPayment(ProcessPaymentRequest request) {
        if (PreProcessPayment != null) PreProcessPayment(ref request); }
      protected void RaisePostProcessPayment(ProcessPaymentRequest request, ProcessPaymentResponse response) {
        if (PostProcessPayment != null) PostProcessPayment(ref request, ref response); }
      protected void RaiseProcessPaymentError(ProcessPaymentRequest request, Exception exception) {
        if (ProcessPaymentError != null) ProcessPaymentError(ref request, ref exception); }
      
      protected void RaisePreSearchPaymentHistory(SearchPaymentHistoryRequest request) {
        if (PreSearchPaymentHistory != null) PreSearchPaymentHistory(ref request); }
      protected void RaisePostSearchPaymentHistory(SearchPaymentHistoryRequest request, SearchPaymentHistoryResponse response) {
        if (PostSearchPaymentHistory != null) PostSearchPaymentHistory(ref request, ref response); }
      protected void RaiseSearchPaymentHistoryError(SearchPaymentHistoryRequest request, Exception exception) {
        if (SearchPaymentHistoryError != null) SearchPaymentHistoryError(ref request, ref exception); }
      
      protected void RaisePreAddPayee(AddPayeeRequest request) {
        if (PreAddPayee != null) PreAddPayee(ref request); }
      protected void RaisePostAddPayee(AddPayeeRequest request, AddPayeeResponse response) {
        if (PostAddPayee != null) PostAddPayee(ref request, ref response); }
      protected void RaiseAddPayeeError(AddPayeeRequest request, Exception exception) {
        if (AddPayeeError != null) AddPayeeError(ref request, ref exception); }
      
        public abstract GetPayeesResponse GetPayees(GetPayeesRequest request);
      
        public abstract ProcessPaymentResponse ProcessPayment(ProcessPaymentRequest request);
      
        public abstract SearchPaymentHistoryResponse SearchPaymentHistory(SearchPaymentHistoryRequest request);
      
        public abstract AddPayeeResponse AddPayee(AddPayeeRequest request);
      GetPayeesResponse  IBillPaymentService.GetPayees(GetPayeesRequest request) {
        GetPayeesResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBillPaymentServiceOperation(request);
        RaisePreGetPayees(request);
        response = GetPayees(request);
        RaisePostGetPayees(request, response);
        RaisePostBillPaymentServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BillPaymentServiceOperationError == null) throw;
          RaiseBillPaymentServiceOperationError(request, exception);
          RaiseGetPayeesError(request, exception); }
        return response; }
      ProcessPaymentResponse  IBillPaymentService.ProcessPayment(ProcessPaymentRequest request) {
        ProcessPaymentResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBillPaymentServiceOperation(request);
        RaisePreProcessPayment(request);
        response = ProcessPayment(request);
        RaisePostProcessPayment(request, response);
        RaisePostBillPaymentServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BillPaymentServiceOperationError == null) throw;
          RaiseBillPaymentServiceOperationError(request, exception);
          RaiseProcessPaymentError(request, exception); }
        return response; }
      SearchPaymentHistoryResponse  IBillPaymentService.SearchPaymentHistory(SearchPaymentHistoryRequest request) {
        SearchPaymentHistoryResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBillPaymentServiceOperation(request);
        RaisePreSearchPaymentHistory(request);
        response = SearchPaymentHistory(request);
        RaisePostSearchPaymentHistory(request, response);
        RaisePostBillPaymentServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BillPaymentServiceOperationError == null) throw;
          RaiseBillPaymentServiceOperationError(request, exception);
          RaiseSearchPaymentHistoryError(request, exception); }
        return response; }
      AddPayeeResponse  IBillPaymentService.AddPayee(AddPayeeRequest request) {
        AddPayeeResponse response = null;
        try {
        
        RaisePreIntegrationServiceOperation(request);
        
        RaisePreBillPaymentServiceOperation(request);
        RaisePreAddPayee(request);
        response = AddPayee(request);
        RaisePostAddPayee(request, response);
        RaisePostBillPaymentServiceOperation(request, response);
        
          RaisePostIntegrationServiceOperation(request, response);
        
        return response;  }
        catch (Exception exception) {
          
          RaiseIntegrationServiceOperationError(request, exception);
          
          // Fire OperationException event.
          if (BillPaymentServiceOperationError == null) throw;
          RaiseBillPaymentServiceOperationError(request, exception);
          RaiseAddPayeeError(request, exception); }
        return response; }
       }
      
      public class BatchBillPaymentService : IBatchBillPaymentService
      {
      private readonly IBillPaymentService service;
      private readonly int maxDegreeOfParallelism;
      public BatchBillPaymentService(IBillPaymentService service, int maxDegreeOfParallelism = 10) {
        this.service = service;
        this.maxDegreeOfParallelism = maxDegreeOfParallelism; }
      private readonly BatchBillPaymentServiceResponse response = new BatchBillPaymentServiceResponse {
        Responses = new ConcurrentDictionary<string, BillPaymentServiceResponse>(),
        Faults = new ConcurrentDictionary<string, BillPaymentServiceFault>() };

      public BatchBillPaymentServiceResponse Process(BatchBillPaymentServiceRequest request) {
        Parallel.ForEach(request.Requests, new ParallelOptions {
          MaxDegreeOfParallelism = maxDegreeOfParallelism },
          ProcessRequest);
           return response; }
           
      private void ProcessRequest(KeyValuePair<string, BillPaymentServiceRequest> keyValuePair) {
      try
      {
      
        if (keyValuePair.Value is GetPayeesRequest)
        response.Responses.Add(keyValuePair.Key, service.GetPayees(keyValuePair.Value as GetPayeesRequest));
      
        if (keyValuePair.Value is ProcessPaymentRequest)
        response.Responses.Add(keyValuePair.Key, service.ProcessPayment(keyValuePair.Value as ProcessPaymentRequest));
      
        if (keyValuePair.Value is SearchPaymentHistoryRequest)
        response.Responses.Add(keyValuePair.Key, service.SearchPaymentHistory(keyValuePair.Value as SearchPaymentHistoryRequest));
      
        if (keyValuePair.Value is AddPayeeRequest)
        response.Responses.Add(keyValuePair.Key, service.AddPayee(keyValuePair.Value as AddPayeeRequest));
      
      }
      catch(FaultException<BillPaymentServiceFault> fault)
      {
      
        if (fault.Detail is GetPayeesFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as GetPayeesFault);
      
        if (fault.Detail is ProcessPaymentFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as ProcessPaymentFault);
      
        if (fault.Detail is SearchPaymentHistoryFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as SearchPaymentHistoryFault);
      
        if (fault.Detail is AddPayeeFault)
        response.Faults.Add(keyValuePair.Key, fault.Detail as AddPayeeFault);
      
      }
      }
      }

      public partial class BillPaymentServiceProxy : ClientBase<IBillPaymentService>, IBillPaymentService
      {
      
        public GetPayeesResponse GetPayees(GetPayeesRequest request)
        {
        return Channel.GetPayees(request);
        }
      
        public ProcessPaymentResponse ProcessPayment(ProcessPaymentRequest request)
        {
        return Channel.ProcessPayment(request);
        }
      
        public SearchPaymentHistoryResponse SearchPaymentHistory(SearchPaymentHistoryRequest request)
        {
        return Channel.SearchPaymentHistory(request);
        }
      
        public AddPayeeResponse AddPayee(AddPayeeRequest request)
        {
        return Channel.AddPayee(request);
        }
      
      }

      public class BatchBillPaymentServiceProxy : ClientBase<IBatchBillPaymentService>, IBatchBillPaymentService
        {
        
          public delegate void GetPayeesResponseHandler(GetPayeesRequest request, GetPayeesResponse response);
          public delegate void GetPayeesFaultHandler(GetPayeesRequest request, GetPayeesFault fault);
          public event GetPayeesResponseHandler GetPayeesResponse;
          public event GetPayeesFaultHandler GetPayeesFault;
        
          public delegate void ProcessPaymentResponseHandler(ProcessPaymentRequest request, ProcessPaymentResponse response);
          public delegate void ProcessPaymentFaultHandler(ProcessPaymentRequest request, ProcessPaymentFault fault);
          public event ProcessPaymentResponseHandler ProcessPaymentResponse;
          public event ProcessPaymentFaultHandler ProcessPaymentFault;
        
          public delegate void SearchPaymentHistoryResponseHandler(SearchPaymentHistoryRequest request, SearchPaymentHistoryResponse response);
          public delegate void SearchPaymentHistoryFaultHandler(SearchPaymentHistoryRequest request, SearchPaymentHistoryFault fault);
          public event SearchPaymentHistoryResponseHandler SearchPaymentHistoryResponse;
          public event SearchPaymentHistoryFaultHandler SearchPaymentHistoryFault;
        
          public delegate void AddPayeeResponseHandler(AddPayeeRequest request, AddPayeeResponse response);
          public delegate void AddPayeeFaultHandler(AddPayeeRequest request, AddPayeeFault fault);
          public event AddPayeeResponseHandler AddPayeeResponse;
          public event AddPayeeFaultHandler AddPayeeFault;
        

        public BatchBillPaymentServiceResponse Process(BatchBillPaymentServiceRequest request) { return Channel.Process(request); }

        public void Process(IList<BillPaymentServiceRequest> requests) { ThreadPool.QueueUserWorkItem(Process, requests); }

        public void Process(object obj)
        {
        var requests = obj as IList<BillPaymentServiceRequest>;
        IDictionary<BillPaymentServiceRequest, BillPaymentServiceResponse> responses;
        IDictionary<BillPaymentServiceRequest, BillPaymentServiceFault> faults;
        Process(requests, out responses, out faults);
        foreach (var item in responses) {
        
          if (item.Key is GetPayeesRequest)
          GetPayeesResponse(item.Key as GetPayeesRequest, item.Value as GetPayeesResponse);
        
          if (item.Key is ProcessPaymentRequest)
          ProcessPaymentResponse(item.Key as ProcessPaymentRequest, item.Value as ProcessPaymentResponse);
        
          if (item.Key is SearchPaymentHistoryRequest)
          SearchPaymentHistoryResponse(item.Key as SearchPaymentHistoryRequest, item.Value as SearchPaymentHistoryResponse);
        
          if (item.Key is AddPayeeRequest)
          AddPayeeResponse(item.Key as AddPayeeRequest, item.Value as AddPayeeResponse);
         }

        foreach (var item in faults) {
        
          if (item.Key is GetPayeesRequest)
          GetPayeesFault(item.Key as GetPayeesRequest, item.Value as GetPayeesFault);
        
          if (item.Key is ProcessPaymentRequest)
          ProcessPaymentFault(item.Key as ProcessPaymentRequest, item.Value as ProcessPaymentFault);
        
          if (item.Key is SearchPaymentHistoryRequest)
          SearchPaymentHistoryFault(item.Key as SearchPaymentHistoryRequest, item.Value as SearchPaymentHistoryFault);
        
          if (item.Key is AddPayeeRequest)
          AddPayeeFault(item.Key as AddPayeeRequest, item.Value as AddPayeeFault);
         }
        }

        public void Process(
        IList<BillPaymentServiceRequest> requests,
        out IDictionary<BillPaymentServiceRequest, BillPaymentServiceResponse> responses,
        out IDictionary<BillPaymentServiceRequest, BillPaymentServiceFault> faults )
        {
        var requestDictionary = requests.ToDictionary(request => Guid.NewGuid().ToString());
        var processResponse = Process(new BatchBillPaymentServiceRequest
        {
        Requests = requestDictionary
        });
        responses = (from resp in processResponse.Responses
        join req in requestDictionary
        on resp.Key equals req.Key
        select new { Request = req.Value, Response = resp.Value })
        .ToDictionary(k => k.Request, v => v.Response);

        faults = (from fault in processResponse.Faults
        join req in requestDictionary
        on fault.Key equals req.Key
        select new { Request = req.Value, Fault = fault.Value })
        .ToDictionary(k => k.Request, v => v.Fault);
        }
        }

      }

      namespace Clients
      {
      public partial class BillPaymentServiceClient : IBillPaymentServiceClient
        {
          public BillPaymentServiceClient(IBillPaymentService service) { Service = service; }
          public IBillPaymentService Service { get; set; }
        }
    }
  }
    
  
  
  
  
  

  
  
  
  
  
  
    
      
    
  

  
    
      
    
  
  
  
  
  
  

  
    
      
            
    
  
  
  
    
      
      
      
    
  

  
    
      
      
      
      
    
  
  
